import re
import sys

def parse_sql_script(sql_script):
    tables = re.findall(r'CREATE TABLE\s+(\w+)\s+\((.*?)\);', sql_script, re.DOTALL)
    schema = {}
    for table in tables:
        table_name = table[0]
        columns = table[1].strip().split(',')
        schema[table_name] = []

        for column in columns:
            if 'PRIMARY' not in column:
                column_name = re.search(r'(\w+)', column).group(1)
                schema[table_name].append(column_name)

    # Extract foreign key relationships
    foreign_keys = re.findall(r'FOREIGN KEY\s+\((\w+)\)\s+REFERENCES\s+(\w+)\((\w+)\);', sql_script)
    for fk in foreign_keys:
        from_column = fk[0]
        from_table = next(table for table in schema.keys() if from_column in schema[table])
        to_table = fk[1]
        to_column = fk[2]
        schema[from_table].append((from_column, to_table, to_column))

    return schema

# Example usage:
if __name__ == '__main__':
    filename = sys.argv[1]
    with open(filename, 'r', encoding='utf-8') as file:
        sql_script = file.read()
        schema = parse_sql_script(sql_script)
        print(schema)

